/*
 * File: DelayTimesForC.c
 *
 * Code generated for Simulink model 'FLTM'.
 *
 * Model version                  : 3.719
 * Simulink Coder version         : 9.4 (R2020b) 29-Jul-2020
 * C/C++ source code generated on : Fri Dec 29 09:53:44 2023
 */

#include "DelayTimesForC.h"

/*
 * Output and update for atomic system:
 *    'DelayTimesForC' ('mylib:191')
 *    'DelayTimesForC' ('mylib:191')
 *    'DelayTimesForC' ('mylib:191')
 *    'DelayTimesForC' ('mylib:191')
 *    'DelayTimesForC' ('mylib:191')
 *    'DelayTimesForC' ('mylib:191')
 *    'DelayTimesForC' ('mylib:191')
 *    'DelayTimesForC' ('mylib:191')
 *    'DelayTimesForC' ('mylib:191')
 *    'DelayTimesForC' ('mylib:191')
 *    ...
 */
void DelayTimesForC(boolean_T T_F, B_DelayTimesForC_T *localB,
                    DW_DelayTimesForC_T *localDW, uint32_T rtp_sysRunTimeTi,
                    uint16_T rtp_time, boolean_T *rtd_ClearFault, uint32_T
                    *rtd_sysRunTime)
{
    int32_T tmp;
    uint16_T Switch1_n;
    uint16_T Switch1_o;
    if ((*rtd_ClearFault) || (*rtd_sysRunTime <= rtp_sysRunTimeTi))
    {
        Switch1_o = 0U;
    }
    else
    {
        Switch1_o = T_F;
    }

    if (Switch1_o != 0)
    {
        Switch1_n = 0U;
    }
    else
    {
        Switch1_n = localDW->UnitDelay1_DSTATE;
    }

    tmp = (localDW->UnitDelay3_DSTATE + Switch1_o) - Switch1_n;
    if (tmp < 0)
    {
        tmp = 0;
    }
    else
    {
        if (tmp > 65535)
        {
            tmp = 65535;
        }
    }

    localB->Compare_ihh3 = ((uint16_T)tmp >= rtp_time);
    localDW->UnitDelay3_DSTATE = (uint16_T)tmp;
    localDW->UnitDelay1_DSTATE = (uint16_T)tmp;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
